extends Node2D

@onready var sprite=$Sprite2D
@onready var check=$RayCast2D

var target=Vector2.ZERO
var dir=Vector2.ZERO
var speed=2000
var hurt=1

func _ready():
	lookTarget()
	pass

func _physics_process(_delta):
	if dir != Vector2.ZERO:
		position+=dir*speed
	checkTarget()
	pass

# 子弹的朝向
func lookTarget():
	look_at(target)

# 子弹射击到物体
func checkTarget():
	var obj=check.get_collider()
	if obj is Enemy:
		obj.getHurt(hurt)
	if obj:
		queue_free()

# 子弹失去动能
func _on_timer_timeout() -> void:
	queue_free()
